package com.atguigu.gmall.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.util.AuthContextHolder;
import com.atguigu.gmall.order.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author: 封捷
 * @create-date: 2022/9/7 9:59
 */
@Controller
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    @RequestMapping("/trade.html")
    public String trade(Model model) {

        // 1、调用远程接口获取数据
        Result<Map<String, Object>> result = orderFeignClient.trade();
        Map<String, Object> resultMap = result.getData();

        // 2、把远程查询到的数据全部存储到模型中
        model.addAllAttributes(resultMap);

        // 3、返回逻辑视图
        return "order/trade";
    }

}
